#Event rezall "Honch tells #*#, 'rezall'"
#Event EvalCorpse "This corpse can be resurrected."
#Event PlayerOffline "There are no players in EverQuest that match those who filters."
|------------------------------------------------------------|

Sub Event_rezall
/if (!${Me.Class.ShortName.Equal[CLR]}) /return
/declare ValidCorpse bool outer FALSE
/declare i int local
/gu I see ${SpawnCount['s radius 200]} nearby corpse spawns.
/target clear
/for i 1 to ${SpawnCount['s radius 200]}
/varset ValidCorpse FALSE
/doevents flush EvalCorpse
/doevents flush PlayerOffline
/target ${NearestSpawn[${i},'s]}
/delay 2
| Check to see if I should actually rez this corpse... ValidCorpse is set to FALSE by default, which means we won't rez.
| EvalCorpse will set ValidCorpse to TRUE if the corpse /con says it's a rezzable corpse. This also negates non-PC corpses.
| If EvalCorpse gave us a true ValidCorpse, then the next step is to check if the corpse's owner is online. So we /who all.
| If we see that there are no players online with that corpse owner's name, we skip it. Otherwise, we assume it's safe to rez.
| This doesn't account for players who might be zoning.
/consider
/delay 1s
/doevents EvalCorpse
/if (${ValidCorpse}) {
/who all ${Target.DisplayName}
/delay 1s
/doevents PlayerOffline
}
/if (${ValidCorpse}) {
/gu Casting Reviviscence on ${Target.DisplayName}.
/call cast "Water Sprinkler of Nem Ankh" item 10s
}
/delay 5
/next i
/target clear
/gu Mass rez finished.
/return

Sub Event_EvalCorpse
/varset ValidCorpse TRUE
/return

Sub Event_PlayerOffline
/varset ValidCorpse FALSE
/if (${Target.DisplayName.Equal[Element]}) /varset ValidCorpse TRUE
/return